package com.usermanage.ServiceImpl;

import com.usermanage.Mapping.GroupPermissionMapping;
import com.usermanage.Service.GroupPermissionService;
import com.usermanage.beanParam.GroupBean;
import com.usermanage.beanParam.GroupPermissionBean;
import com.usermanage.beanParam.UserBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * Created by 過客 on 2018/3/9
 */
@Service("groupPermissionService")
public class GroupPermissionServiceImpl implements GroupPermissionService {

    @Resource
    private GroupPermissionMapping groupPermissionMapping;

    @Override
    public List<Integer> getBasePermission() {
        return groupPermissionMapping.getBasePermission();
    }

    @Override
    public boolean isExsit(GroupPermissionBean bean) {
        Example<GroupPermissionBean> example = Example.of(bean);
        boolean bool = groupPermissionMapping.exists(example);
        return bool;
    }

    @Override
    public GroupPermissionBean save(GroupPermissionBean bean) {
        return groupPermissionMapping.save(bean);
    }

    @Override
    public Optional findById(int id) {
        return groupPermissionMapping.findById(id);
    }

    @Override
    public List<GroupPermissionBean> findAll(GroupPermissionBean bean) {
        Example<GroupPermissionBean> example = Example.of(bean);
        return groupPermissionMapping.findAll(example);
    }

    @Override
    public void delete(GroupPermissionBean bean) {
        groupPermissionMapping.delete(bean);
    }

    @Override
    public void deleteById(int id) {
        groupPermissionMapping.deleteById(id);
    }


}
